﻿<UserControl x:Class="Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.UI.CodeAnalysisResultContent"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local.ui="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.UI"
             x:Name="this"
             mc:Ignorable="d" 
             d:DesignHeight="300"
             d:DesignWidth="600">
    <Grid Name="layoutRoot" Margin="5" MinWidth="500">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
            <Popup Name="howToSearchPopup" AllowsTransparency="True" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=searchTextBox}" VerticalOffset="15" Height="200" Width="500">
                <local.ui:HowToSearchControl/>
            </Popup>
            <TextBox Name="searchTextBox" Width="250"/>
            <Button IsDefault="True" Margin="1,0,0,0" Command="{Binding SearchCommand}" CommandParameter="{Binding Text, ElementName=searchTextBox}">
                <Image Source="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Search.png"/>
            </Button>
        </StackPanel>
        <TextBlock Grid.Row="1" FontSize="10" HorizontalAlignment="Right">
            <Hyperlink Click="ToggleHowToSearchPopupVisibility">How to search ?</Hyperlink>
        </TextBlock>
        <ListView Name="problemsListView" Grid.Row="2" ItemsSource="{Binding CurrentPageProblems}" IsSynchronizedWithCurrentItem="True" Margin="0,5">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <EventSetter Event="MouseDoubleClick" Handler="OnProblemDoubleClicked" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="" Width="25">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image>
                                    <Image.Style>
                                        <Style TargetType="Image">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Kind}" Value="Target">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Assembly.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Module">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Assembly.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Namespace">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Namespace.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Resource">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Resource.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Class">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Class.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Delegate">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Delegate.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Enum">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Enum.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Interface">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Interface.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Struct">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Struct.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Constructor">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Method.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Event">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Event.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Field">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Field.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Method">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Method.png"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Kind}" Value="Property">
                                                    <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/Property.png"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Project" Width="80" DisplayMemberBinding="{Binding ProjectName}"/>
                    <GridViewColumn Header="File" Width="80" DisplayMemberBinding="{Binding FileName}"/>
                    <GridViewColumn Header="Check Id" Width="80" DisplayMemberBinding="{Binding CheckId}"/>
                    <GridViewColumn Header="Category" Width="120" DisplayMemberBinding="{Binding Category}"/>
                    <GridViewColumn Header="Message" Width="400">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" VerticalAlignment="Center">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} problems matched (total {1} problems)">
                        <Binding Path="Count"/>
                        <Binding Path="Problems.Count"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
            <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Margin="2" Command="{Binding GoToFirstPageCommand}">
                    <Image>
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="True">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToFirst.png"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToFirst_Disabled.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button Margin="2" Command="{Binding GoToPrevPageCommand}">
                    <Image>
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="True">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToPrev.png"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToPrev_Disabled.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <TextBlock Margin="2" VerticalAlignment="Center">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0} / {1}">
                            <Binding Path="CurrentPage"/>
                            <Binding Path="TotalPage"/>
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <Button Margin="2" Command="{Binding GoToNextPageCommand}">
                    <Image>
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="True">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToNext.png"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToNext_Disabled.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button Margin="2" Command="{Binding GoToLastPageCommand}">
                    <Image>
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="True">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToLast.png"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                        <Setter Property="Source" Value="pack://application:,,,/Sasa.QualityTools.CodeAnalysis.FxCopIntegrator;component/Resources/GoToLast_Disabled.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
